home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr08 / addcli.zip / ADDCLIP.CLW next >
Text File  |  1995-03-11  |  9KB  |  276 lines

  1.  PROGRAM
  2.  
  3.  omit('!@')
  4.  ----------------------------------------------------------------------
  5.  This program will add the contents of the Windows(tm) clipboard
  6.  when those contents have been copied or cut from a column of numbers
  7.  such as might be found in an MS WinWord Table or a word processing
  8.  document.
  9.  Step one: highlight and copy (or cut) to the clipboard with CTRL-C or
  10.  CTRLX a column of figures for example:
  11.     1.34
  12.     23.1
  13.     129
  14.     8
  15.     123.91
  16.  Alignment isn't important.
  17.  
  18.  Step two: Start this "Add Clip Board" program. Press the paste button
  19.  and your column of figures will appear in the left hand list followed
  20.  by an underline and a total.
  21.  
  22.  If you need to do any sub totalling, numbers from the left hand list can
  23.  be dragged and dropped into the right hand list and vice versa.
  24.  
  25.  Finally: Your total can be copied back into the clipboard by pressing
  26.  the copy button on either list.
  27.  
  28.  On returning to your application, press CTRL-V to paste the result.
  29.  ---------------------------------------------------------------------
  30.  Gus M. Creces
  31.  631 CloverPark Crescent
  32.  Milton, ON, L9T 4T7 Canada
  33.  (905) 878-5174 CIS-72073,1724
  34.  ---------------------------------------------------------------------
  35.   !@
  36.  
  37.  include('keycodes.clw')             !Clarion standard keyboard constants
  38.  include('equates.clw')              !Clarion standard program constants
  39.  include('errors.clw')               !Clarion standard error constants
  40.  
  41.  
  42. ClipID           equate('CLIPLIST')
  43. SubID            equate('SUBLIST')
  44. ProgramName      equate('Add Clip Board')
  45. UnderLine        equate('====================')
  46. Cr_Lf            equate('<13><10>')
  47. Total            Real
  48. ClipBd           string(512)
  49. SubTtl           real
  50. ClipChoice       long
  51. SubChoice        long
  52. MessageString    string(1050)
  53.  
  54. ClipTable queue,pre(CT)
  55.           string(20)
  56.           end
  57.  
  58. SubTable  queue,pre(ST)
  59.           string(20)
  60.           end
  61.  
  62. Window WINDOW(ProgramName),AT(38,25,193,108),FONT('Arial',8,,FONT:regular),ICON('CLIPBD.ICO'),STATUS, |
  63.          SYSTEM,GRAY,DOUBLE,AUTO
  64.        TOOLBAR,AT(0,0,193,12)
  65.          BUTTON('E&xit'),AT(9,1,22,10),FONT('Arial',0,,),MSG('Exit: '),USE(?ExitButton),SKIP
  66.          BUTTON('&Help'),AT(33,1,22,10),FONT('Arial',0,,),MSG('How to use: '),USE(?HelpButton),SKIP
  67.        END
  68.        GROUP,AT(2,1,91,92),USE(?ClipGroup),BOXED
  69.          LIST,AT(23,14,65,76),FONT('Arial',8,,),USE(?ClipList),NOBAR,VSCROLL,FORMAT('21R(1)~Clip Board~L@s20@'), |
  70.              FROM(ClipTable),DRAGID(ClipID),DROPID(SubID)
  71.          BUTTON('Read'),AT(4,14,16,12),MSG('Reread contents of clipboard.'),KEY(CtrlV),USE(?ClipReadButton), |
  72.              SKIP,ICON(ICON:Paste)
  73.          BUTTON('Copy'),AT(4,29,16,12),MSG('Copy the highlighted entry to the clipboard.'),USE(?ClipCopy), |
  74.              SKIP,ICON(ICON:Copy)
  75.          BUTTON('Cut'),AT(4,44,16,12),MSG('Cut the highlighted list entry.'),USE(?ClipCut),SKIP,ICON(ICON:Cut)
  76.          BUTTON('Clr'),AT(4,60,16,12),MSG('Clear the "Clipboard" list.'),USE(?ClipClear),SKIP,ICON(ICON:VCRrewind)
  77.        END
  78.        GROUP,AT(97,1,91,92),USE(?SubGroup),BOXED
  79.          LIST,AT(119,14,65,76),FONT('Arial',8,,),USE(?SubList),NOBAR,VSCROLL,FORMAT('21R(1)~SubTotals~L@s20@'), |
  80.              FROM(SubTable),DRAGID(SubID),DROPID(ClipID)
  81.          BUTTON('Copy'),AT(100,14,16,12),MSG('Copy the highlighted entry to the clipboard.'),USE(?SubCopy), |
  82.              SKIP,ICON(ICON:Copy)
  83.          BUTTON('Cut'),AT(100,29,16,12),MSG('Cut the highlighted list entry.'),USE(?SubCut),SKIP,ICON(ICON:Cut)
  84.          BUTTON('Clr'),AT(100,43,16,12),MSG('Clear the "Subtotal" list.'),USE(?SubClear),SKIP,ICON(ICON:VCRrewind)
  85.        END
  86.      END
  87.  
  88.   MAP
  89.    TotalQueue(*Queue)
  90.    InitQueue(*Queue)
  91.    AddUnderLine(*Queue)
  92.   END
  93.  
  94.   CODE
  95.   InitQueue(ClipTable)
  96.   InitQueue(SubTable)
  97.  
  98.   OPEN(Window)
  99.   ACCEPT
  100.  
  101.   CASE event()
  102.   OF Event:Drag
  103.      if DragID() = ClipID
  104.        get(ClipTable,choice())
  105.        SetDropID(ClipID)
  106.      elsif DragID() = SubID then
  107.        get(SubTable,choice())
  108.        SetDropID(SubID)
  109.      end
  110.  
  111.   OF Event:Drop
  112.      if DropID() = ClipID then
  113.        SubTable = ClipTable
  114.        if not instring('==',SubTable,1,1) then
  115.         add(SubTable,1)
  116.         TotalQueue(SubTable)
  117.       end
  118.     elsif DropID() = SubID then
  119.       ClipTable = SubTable
  120.       if not instring('==',ClipTable,1,1) then
  121.        add(ClipTable,1)
  122.        TotalQueue(ClipTable)
  123.       end
  124.     end
  125.   END
  126.  
  127.   if inrange(field(),?ClipGroup,?ClipClear) and not ClipChoice then
  128.      ClipChoice = true
  129.      SubChoice = false
  130.      select(?ClipList,1)
  131.      cycle
  132.   end
  133.  
  134.   if inrange(field(),?SubGroup,?SubClear) and not SubChoice then
  135.      ClipChoice = false
  136.      SubChoice = true
  137.      select(?SubList,1)
  138.      cycle
  139.   end
  140.  
  141.   CASE accepted()
  142.  
  143.   OF ?ClipList
  144.      if keycode() = mouseleft then
  145.       ClipChoice = choice()
  146.      end
  147.  
  148.   OF ?SubList
  149.      if keycode() = mouseleft then
  150.       SubChoice = choice()
  151.      end
  152.  
  153.   OF ?ClipCut
  154.      if inrange(ClipChoice,1,records(ClipTable) - 1) then
  155.       get(ClipTable,ClipChoice)
  156.       delete(ClipTable)
  157.      end
  158.      TotalQueue(ClipTable)
  159.  
  160.  
  161.   OF ?SubCut
  162.      if inrange(SubChoice,1,records(SubTable) - 1) then
  163.       get(SubTable,SubChoice)
  164.       delete(SubTable)
  165.      end
  166.      TotalQueue(SubTable)
  167.  
  168.   OF ?ClipClear
  169.      InitQueue(ClipTable)
  170.  
  171.   OF ?SubClear
  172.      InitQueue(SubTable)
  173.  
  174.   OF ?ClipCopy
  175.      if ClipChoice then
  176.       get(ClipTable,ClipChoice)
  177.       setclipboard(clip(left(ClipTable)) & Cr_Lf)
  178.      end
  179.  
  180.   OF ?SubCopy
  181.      if SubChoice then
  182.       get(SubTable,SubChoice)
  183.       setclipboard(clip(left(SubTable)) & Cr_Lf)
  184.      end
  185.  
  186.   OF ?ClipReadButton
  187.      ClipBd = ClipBoard()
  188.      free(ClipTable)
  189.      Total = 0
  190.      s# = 1
  191.      e# = instring(Cr_Lf,ClipBd,1,1)
  192.      if not e# and clip(ClipBd) > '' then
  193.        e# = len(Clip(ClipBd)) + 1
  194.      end
  195.      loop while e#
  196.        SubTtl = deformat(clipbd[s#:e#])
  197.        if SubTtl > 0 then
  198.         ClipTable = format(SubTtl,@N20.2)
  199.         add(ClipTable)
  200.        end
  201.        s# = e# + 2
  202.        e# = instring(Cr_Lf,clipbd,1,s#)
  203.      end
  204.      AddUnderLine(ClipTable)
  205.      TotalQueue(ClipTable)
  206.  
  207.   OF ?ExitButton
  208.      break
  209.  
  210.   OF ?HelpButton
  211.      MessageString = |
  212.      'This program reads numerical entries into a list from the ' & |
  213.      Cr_Lf & 'Windows(tm) clip board and adds them up. Any entry in ' & |
  214.      Cr_Lf & 'the "Clip Board" list may be dragged into the ' & |
  215.      Cr_Lf & '"Sub Total" list which then automatically re-totals. '&|
  216.      Cr_Lf & 'Several columns of discontinuous numbers, thus, can '& |
  217.      Cr_Lf & 'be copied to the clipboard, and totalled. These totals'&|
  218.      Cr_Lf & 'can be dragged to the "Sub Total" list where they too may'&|
  219.      Cr_Lf & 'be separately totalled. Any entry in the "Sub Total" list '&  |
  220.      Cr_Lf & 'may be dragged into the "Clip Board" list which then re-totals.' & Cr_Lf & |
  221.      Cr_Lf & 'The PASTE button "pastes" entries from the clipboard.'& Cr_Lf & |
  222.      Cr_Lf & 'The SCISSORS button cuts the highlighted entry from the  '&|
  223.      Cr_Lf & 'list next to it. ' & Cr_Lf & |
  224.      Cr_Lf & 'The COPY button copies the highlighted entry'&|
  225.      Cr_Lf & 'to the clipboard, so that the end value derived may '&|
  226.      Cr_Lf & 'be pasted back into an orignating application such' & |
  227.      Cr_Lf & 'as MS WinWord.'& Cr_Lf & |
  228.      Cr_Lf & 'The REWIND button clears the list next to it. '&  Cr_Lf &|
  229.      Cr_Lf & 'This program was written by ' & |
  230.      Cr_Lf & 'Gus M. Creces'& |
  231.      Cr_Lf & '631 CloverPark Crescent, Milton ON, L9T 4T7 Canada.' & |
  232.      Cr_Lf & '(905) 878-5174 CIS-72073,1724 '
  233.  
  234.  
  235.      d# = Message(clip(MessageString),ProgramName,ICON:Question)
  236.   ..
  237.   Return
  238.  
  239.  
  240.  
  241. !----------------------------
  242. TotalQueue Procedure(xQueue)
  243. !----------------------------
  244.   CODE
  245.   loop 2 times
  246.     get(xQueue,records(xQueue))
  247.     delete(xQueue)
  248.   end
  249.   Total = 0
  250.   loop i# = 1 to records(xQueue)
  251.     get(xQueue,i#)
  252.     SubTtl = deformat(xQueue)
  253.     Total += Subttl
  254.   end
  255.   AddUnderLine(xQueue)
  256.  
  257. !-----------------------------
  258. AddUnderline Procedure(xQueue)
  259. !-----------------------------
  260.   CODE
  261.   xQueue = UnderLine
  262.   add(xQueue)
  263.   xQueue = format(Total,@N20.2)
  264.   add(xQueue)
  265.  
  266. !--------------------------------
  267. InitQueue Procedure(xQueue)
  268. !--------------------------------
  269.   CODE
  270.   free(xQueue)
  271.   xQueue = UnderLine
  272.   add(xQueue,1)
  273.   xQueue = format(0,@N20.2)
  274.   add(xQueue,2)
  275.  
  276.